#include<bits/stdc++.h>
using namespace std;
struct edge{
    int l,r;
}k[25][100005];
vector<edge>sta;
int T,n[25],m,L,V,ans1,ans2,cnt,d[100005],v[100005],a[100005],p[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    for(int t=1;t<=T;t++){
        ans1=0;
    scanf("%d%d%d%d",n+t,&m,&L,&V);
    for(int i=1;i<=n[t];i++)
        scanf("%d%d%d",d+i,v+i,a+i);
    for(int i=1;i<=m;i++)
        scanf("%d",p+i);
    for(int i=1;i<=n[t];i++){
        if(a[i]==0 && v[i]>V)
            k[t][i].l=d[i],k[t][i].r=L+1;
        else if(a[i]>0){
            if(v[i]>V)
                k[t][i].l=d[i],k[t][i].r=L+1;
            else{
                double s=(V*V-v[i]*v[i])*1.0/(2*a[i]);
                k[t][i].l=ceil(s)+d[i],k[t][i].r=L+1;
                if(k[t][i].l>L || (k[t][i].l==L && s==ceil(s)))
                    k[t][i].l=0,k[t][i].r=0;
            }
        }
        else{
            if(v[i]>V){
                double s=(v[i]*v[i]-V*V)*1.0/(2*(-a[i]));
                k[t][i].l=d[i],k[t][i].r=floor(s)+d[i];
                if(k[t][i].r>L)
                    k[t][i].r=L+1;
            }
        }
    }
    int mi=INT_MAX,ma=0;
    for(int i=1;i<=n[t];i++){
        if(!k[t][i].l && !k[t][i].r)
            continue;
        int k1=upper_bound(p+1,p+m+1,k[t][i].l)-p,k2=lower_bound(p+1,p+m+1,k[t][i].r)-p;
        int s1=p[k1],s2=p[k2];
        if(a[i]==0 && k[t][i].l>p[m])
            continue;
        if(a[i]>0 && (k[t][i].l>=p[m]))
            continue;
        if(k1<k2 || (k1==k2 && k[t][i].l!=s1 && k[t][i].r!=s2))
            ans1++,sta.push_back({k1,k2}),mi=min(mi,k1),ma=max(ma,k2);
    }
    printf("%d %d\n",ans1,(ans1?m-1:m));
    }
    return 0;
}
